<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:au="http://java.sun.com/jsf/composite/autocomplete">


    <ui:define name="content">

        <h:panelGroup >
            <h:form  >

                <p:focus id="selectFocus" context="gpSelect" />
                <p:focus id="detailFocus" context="gpDetail" />



                <p:panel >
                    <f:facet name="header" >
                        <p:outputLabel value="Manage Institutions" ></p:outputLabel>
                        <p:commandButton id="btnBack" value="Back" 
                                         action="/admin_mange_institutions_index" style="float: right;"
                                         ajax="false">
                        </p:commandButton>

                    </f:facet>

                    <div id="Temp" style="position: relative;left:0%;">
                        <h:panelGrid id ="gpVeda" columns="2" styleClass="alignTop">

                            <h:panelGrid id="gpSelect" columns="1"  >

                                <p:panel >
                                    <f:facet name="header" >
                                        <p:outputLabel value="Search" ></p:outputLabel>
                                        <p:commandButton ajax="false" id="btnAdd" value="Add New" 
                                                         action="#{institutionController.prepareAdd()}" 
                                                         style="float: right;">
                                        </p:commandButton>
                                    </f:facet>
                                    <h:panelGrid id="gpSelectText" >
                                        <p:inputText autocomplete="off" id="txtSearch" value="#{institutionController.selectText}" >
                                            <f:ajax execute="txtSearch" render="lstSelect" event="keyup" />
                                        </p:inputText>

                                        <p:selectOneListbox  id="lstSelect"   value="#{institutionController.current}" style="min-width: 223px; height: 300px;">
                                            <f:selectItems  value="#{institutionController.selectedItems}" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.name}" ></f:selectItems>
                                            <p:ajax event="change"   update="gpDetail" process="lstSelect" >
                                            </p:ajax>
                                        </p:selectOneListbox>

                                    </h:panelGrid>
                                    <h:panelGrid id="gpSelectButtons" columns="3"  >

                                        <p:commandButton ajax="false" id="btnDelete" onclick="if (!confirm('Are you sure you want to delete this record?'))
                                                    return false;" action="#{institutionController.delete()}"  value="Delete"  >
                                        </p:commandButton>

                                    </h:panelGrid>
                                </p:panel>
                            </h:panelGrid  >

                            <p:panel>
                                <f:facet name="header" >
                                    <p:outputLabel value="Details" ></p:outputLabel>
                                    <p:commandButton ajax="false" id="btnSave" value="Save" 
                                                     action="#{institutionController.saveSelected()}" styleClass="buttons"
                                                     style="float: right;">
                                    </p:commandButton>
                                    <p:defaultCommand target="btnSave"/>
                                </f:facet>
                                <h:panelGrid id="gpDetail" columns="1">

                                    <p:tabView >
                                        <p:tab title="Basic Details" >
                                            <h:panelGrid id="gpDetailText" columns="2">


                                                <h:outputText id="lblName" value="Name"  ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtName" 
                                                             styleClass="longText"
                                                             value="#{institutionController.current.name}"  ></p:inputText>

                                                <h:outputText id="lblChqPrnName" value="Printi Name" ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtChqPrnName" 
                                                             styleClass="longText"
                                                             value="#{institutionController.current.chequePrintingName}"  ></p:inputText>

                                                <h:outputText value="Code" >                                        
                                                </h:outputText>
                                                <p:inputText autocomplete="off"  value="#{institutionController.current.institutionCode}"  >
                                                </p:inputText> 
                                                <h:outputText value="Point of Issue No" >                                        
                                                </h:outputText>
                                                <p:inputText autocomplete="off"  value="#{institutionController.current.pointOfIssueNo}"  >
                                                </p:inputText> 
                                                <h:outputText value="Descreption" >                                        
                                                </h:outputText>
                                                <p:inputTextarea styleClass="longText" value="#{institutionController.current.descreption}"  >
                                                </p:inputTextarea> 

                                                <h:outputText id="lblType" value="Type" ></h:outputText>
                                                <p:selectOneMenu value="#{institutionController.current.institutionType}">
                                                    <f:selectItem itemLabel="Select Institution Type"/>
                                                    <f:selectItems value="#{institutionController.institutionTypes}"/>
                                                </p:selectOneMenu>
                                                <h:outputText value="Credit Limit" >                                        
                                                </h:outputText>
                                                <p:inputText autocomplete="off"  value="#{institutionController.current.allowedCredit}"  >
                                                </p:inputText>

                                                <h:outputText id="lblPhone" value="Phone" ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtPhone" value="#{institutionController.current.phone}"  ></p:inputText>

                                                <h:outputText id="lblFax" value="Fax" ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtFax" value="#{institutionController.current.fax}"  ></p:inputText>

                                                <h:outputText id="lblEMail" value="Email" ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtEmail" value="#{institutionController.current.email}"  ></p:inputText>

                                                <h:outputText id="lblEMailOwner" value="Owner Email" ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtOwnerEmail" value="#{institutionController.current.ownerEmail}"  ></p:inputText>


                                                <h:outputText id="lblAdress" value="Address" ></h:outputText>
                                                <p:inputTextarea id="txtAdress" value="#{institutionController.current.address}" styleClass="longText" ></p:inputTextarea>

                                                <h:outputText id="lblWeb" value="Web" ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtWeb" value="#{institutionController.current.web}"  ></p:inputText>

                                                <h:outputText id="lblBank" value="Bank" ></h:outputText>
                                                <au:completeBank_Branch value="#{institutionController.current.bankBranch}" />

                                                <h:outputText id="lblAcc" value="Account No" ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtAcc" value="#{institutionController.current.accountNo}"  ></p:inputText>

                                            </h:panelGrid>
                                        </p:tab>
                                        <p:tab title="Advanced" >
                                            <h:panelGrid columns="2" >
                                                <h:outputText  value="Email Sending Account" ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtEmUn" value="#{institutionController.current.emailSendingUsername}"  ></p:inputText>

                                                <h:outputText  value="Email Sending Password" ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtEmPs" value="#{institutionController.current.emailSendingPassword}"  ></p:inputText>

                                                <h:outputText  value="SMS Sending Username" ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtSmsUn" value="#{institutionController.current.smsSendingUsername}"  ></p:inputText>

                                                <h:outputText  value="SMS Sending Password" ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtSmsPs" value="#{institutionController.current.smsSendingPassword}"  ></p:inputText>

                                                <h:outputText  value="SMS Alias" ></h:outputText>
                                                <p:inputText autocomplete="off" id="txtSmsAlias" value="#{institutionController.current.smsSendingAlias}"  ></p:inputText>


                                            </h:panelGrid>
                                        </p:tab>
                                    </p:tabView>



                                </h:panelGrid>

                            </p:panel>


                        </h:panelGrid>

                    </div>
                </p:panel>
            </h:form>

        </h:panelGroup>

    </ui:define>

</ui:composition>
